################################
#
#     Makefile SECONDO ASSEGNAMENTO AA 2019/20
#    
################################


# file da consegnare
# modificare se si aggiungono file
FILE_DA_CONSEGNARE=bbgame.c

# preferenze compilatore e flag di compilazione
CC=gcc
# compilazione 
CFLAGS= -Wall -pedantic -g

obj = bbgame.o



# phony targets
.PHONY: cleanall test1 test2 test3 consegna 


bbgame0 : 00test.o $(obj)
	gcc $(obj) 00test.o -o bbgame0 -lm

bbgame1 : 01test.o $(obj)
	gcc $(obj) 01test.o -o bbgame1 -lm

bbgame2 : 02test.o $(obj)
	gcc $(obj) 02test.o -o bbgame2 -lm

bbgame3 : 03test.o $(obj)
	gcc $(obj) 03test.o -o bbgame3 -lm

bbgame4 : 04test.o $(obj)
	gcc $(obj) 04test.o -o bbgame4 -lm


bbgame.o: bbgame.c bbgame.h  
01test.o: 01test.c bbgame.h   
02test.o: 02test.c bbgame.h   
03test.o: 03test.c bbgame.h   
04test.o: 04test.c bbgame.h   

bbgame: $(obj) main.o
	gcc $(obj) main.o -o bbgame -lm


cleanall: 
	-rm -f *.o *~ ./core bbgame? bbgame



test1:
	make cleanall
	make bbgame1
	./bbgame1 
	@echo "********** Test1 superato!"

test2: 
	make cleanall
	make bbgame2
	./bbgame2
	@echo "********** Test2 superato!"

test3:
	make cleanall
	rm -f test_highscores.txt
	make bbgame3
	./bbgame3
	cat test_highscores.txt
	@echo "********** Test3 superato!"

test4: 
	make cleanall
	make bbgame4
	./bbgame4
	@echo "********** Test4 superato!"

consegna:
	make cleanall
	make test1
	make test2
	make test3
	./gruppo-check.pl < gruppo.txt
	tar -cvf Cognome.Nome-corsoX-a2.tar ./gruppo.txt  $(FILE_DA_CONSEGNARE) 
	@echo "********** TAR creato! Rinominare e inviare in allegato a una mail al docente del proprio corso insieme a nome, cognome,  numero di matricola dei componenti del gruppo"
